<?php

$userid         	= get_loggedin_userid();
$interest_id    	= get_input('interest_id');
$rating         	= get_input('rating');

// params
$lat			= get_input('lat');
$lng			= get_input('lng');
$descriptive_text 	= get_input('descriptive');
$image_url		= get_input('image_url');

$rating_id = add_interest_rating($interest_id, $userid, $rating);

if($rating_id) {
	if ($image_url) {
            add_photo($interest_id, $image_url);
	}
	add_interest_location($interest_id, $lat, $lng);
	add_opinions_stream($userid, $userid, $rating_id, '3', 'no', '');
    echo json_encode(export_result(200, array($rating_id)));
} else {
    echo json_encode(export_result(200, array()));
}
?>